Skip to content

Rework telemetry to support durable execution case#219

Merged
anbuzin merged 4 commits into
mainfrom
durable-telemetry-2
Jul 22, 2026
Merged

Rework telemetry to support durable execution case#219
anbuzin merged 4 commits into
mainfrom
durable-telemetry-2

Conversation

@anbuzin

@anbuzin anbuzin commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator
  1. convert Span to pydantic so they can travel as json
  2. introduce Sink that all spans go to. default sink is the adapter registry. users can explicitly swap it out with a different sink using a context manager. in the workflow body:
sink = ai.telemetry.Collector()
with use_sink(sink):
    # do the stuff
    
await send_spans_step(sink.finished)  # send all spans in a step
  1. spans no longer have methods that immediately send them to adapters. instead, you can mutate span's attributes, then call span.push to send the updated version to the sink.

the async with span("foo") as sp api didn't change much, actually, it's just different under the hood. the Adapter api hasn't changed at all.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment Jul 22, 2026 5:22pm

@msullivan msullivan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically looks good.

I think we should meditate on the differences and similarities between Sinks and Adapters before we finalize it

Comment thread src/ai/experimental_telemetry/otel.py Outdated
Comment thread src/ai/experimental_telemetry/otel.py Outdated
Comment thread src/ai/experimental_telemetry/span.py Outdated
Comment thread src/ai/experimental_telemetry/span.py

@dataclasses.dataclass
class RunSpanData:
class RunSpanData(pydantic.BaseModel):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to put all the "generic telemetry adapter" code in a separate file from the ai-specific stuff.

That's probably best in a follow-up PR though, at this point

Comment thread src/ai/experimental_telemetry/span.py
@anbuzin
anbuzin force-pushed the durable-telemetry-2 branch from 023dbd1 to 69075d8 Compare July 22, 2026 17:21
@anbuzin
anbuzin merged commit 61da20b into main Jul 22, 2026
8 checks passed
@anbuzin
anbuzin deleted the durable-telemetry-2 branch July 22, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants